/**
 * @author 小泽玛丽罗
 * 
 */
var is_commons = 0;
var toast = {
	/**
	 * 成功提示
	 * 
	 * @param text
	 *            内容
	 * @param title
	 *            标题
	 */
	success : function(text, title) {
		toastr.options = {
			"closeButton" : true,
			"debug" : false,
			"positionClass" : "toast-center",
			"onclick" : null,
			"showDuration" : "1000",
			"hideDuration" : "1000",
			"timeOut" : "5000",
			"extendedTimeOut" : "1000",
			"showEasing" : "swing",
			"hideEasing" : "linear",
			"showMethod" : "fadeIn",
			"hideMethod" : "fadeOut"
		};
		toastr.success(text, title);
	},
	/**
	 * 失败提示
	 * 
	 * @param text
	 *            内容
	 * @param title
	 *            标题
	 */
	error : function(text, title) {
		toastr.options = {
			"closeButton" : true,
			"debug" : false,
			"positionClass" : "toast-center",
			"onclick" : null,
			"showDuration" : "1000",
			"hideDuration" : "1000",
			"timeOut" : "3000",
			"extendedTimeOut" : "1000",
			"showEasing" : "swing",
			"hideEasing" : "linear",
			"showMethod" : "fadeIn",
			"hideMethod" : "fadeOut"
		};
		toastr.error(text, title);
	},
	/**
	 * 信息提示
	 * 
	 * @param text
	 *            内容
	 * @param title
	 *            标题
	 */
	info : function(text, title) {
		toastr.options = {
			"closeButton" : false,
			"debug" : false,
			"positionClass" : "toast-center",
			"onclick" : null,
			"showDuration" : "1000",
			"hideDuration" : "1000",
			"timeOut" : "3000",
			"extendedTimeOut" : "1000",
			"showEasing" : "swing",
			"hideEasing" : "linear",
			"showMethod" : "fadeIn",
			"hideMethod" : "fadeOut"
		};
		toastr.info(text, title);
	},
	/**
	 * 警告提示
	 * 
	 * @param text
	 *            内容
	 * @param title
	 *            标题
	 */
	warning : function(text, title) {
		toastr.options = {
			"closeButton" : false,
			"debug" : false,
			"positionClass" : "toast-center",
			"onclick" : null,
			"showDuration" : "1000",
			"hideDuration" : "1000",
			"timeOut" : "3000",
			"extendedTimeOut" : "1000",
			"showEasing" : "swing",
			"hideEasing" : "linear",
			"showMethod" : "fadeIn",
			"hideMethod" : "fadeOut"
		};
		toastr.warning(text, title);
	}
};

jQuery(function($) {
	$(document).ready(function() {
		// enabling stickUp on the '.navbar-wrapper' class
		$('.nav_bar').stickUp();
		$("#main-container").width(1080);
		$("#main-container").css("margin-bottom", 50);
		//开启前端验证框架
		 $("input,select,textarea").not("[type=submit]").jqBootstrapValidation(); 
	});
});

/**
 * 绑定点击事件
 */
$(function() {
	/**
	 * 通用 用以检查表单提交前  input  和select 是否选择有效值
	 */
	$(".validationBeforeSubmit").on('click',function(){
		var $form=$(this).parents("form");
		var inputcount=0;
		var selectcount=0;
		$form.find("input.required").each(function(){
			var value=$(this).val();
			if(value==""||value==null){
				inputcount++;
			}
		});
		$form.find("select.required").each(function(i,element){
			var value=parseInt($(this).val());
			if(value==0){
				selectcount++;
			}
		});
		if(selectcount!=0||inputcount!=0){
			toast.error("请填写和选择必要信息和类型", "温馨提示");
		}else{
			$form.submit();
		}
	});
	
	/**
	 * 分页插件 通用
	 */
	$(".pagePre").on('click' ,function(){
		var $form=$(this).parent();
		var currentPage=$form.find(".currentPage").val()-1;
		$form.find(".currentPage").val(currentPage);
		$form.submit();
	});
	$(".pageNext").on('click' ,function(){
		var $form=$(this).parent();
		var currentPage=parseInt($form.find(".currentPage").val())+1;
		$form.find(".currentPage").val(currentPage);
		$form.submit();
	});
	$("#seasonSave").on('click',function(){
		var season=$("#season").val();
		$.ajax({
			type:"post",
			data:{configId:season},
			url:"seasonConfig.action",
			success:function(data){
				toast.success("季度考核设置成功", "温馨提示");
			},
			error:function(data){
				toast.error("保存失败，请再试", "温馨提示");
			}
			
		});
	});
	$(".dl").on('click',function(){
		var dlId=$(this).attr('id');
		window.location="/mbkhxt/maintainKhForm.action?dlId="+dlId+"&type=new";
	});
	//已生成的考核表的事件绑定
	$(".khbr").on('click',function(){
		var dxId=$(this).find("#dxId").val();
		var formId=$(this).find("#formId").val();
		
		window.location="/mbkhxt/getDxFormKhbAction.action?dxId="+dxId+"&formId="+formId;
	});
	//已生成考核表的事件绑定，进入进度考核表
	$(".khbjd").on('click',function(){
		var dxId=$(this).find("#dxId").val();
		var formId=$(this).find("#formId").val();
		
		window.location="/mbkhxt/getDxProgressKhb.action?dxId="+dxId+"&formId="+formId;
	});
	//已生成的考核表的事件绑定
	$(".khbrDept").on('click',function(){
		var dxId=$(this).find("#dxId").val();
		var formId=$(this).find("#formId").val();
		var deptId=$(this).find("#deptId").val();
		window.location="/mbkhxt/getDeptKhZbAction.action?dxId="+dxId+"&formId="+formId+"&deptId="+deptId;
	});
	//生成真正的对应的考核表
	$("#creatFormReal").on('click',function(){
		var formId=$(this).val();
		var khmbflid=$("#khmbflid").val();
		$.ajax({
			type:"post",
			data:{formId:formId},
			url:"createKhbReal.action",
			success:function(data){
				setTimeout(function(data){
					window.location="/mbkhxt/editKhMb.action?id="+khmbflid;
				},1500);
				toast.success("生成表成功", "温馨提示");
			},
			error:function(data){
				toast.error("失败", "温馨提示");
			}
		});
	});
	//大类中目标表的点击事件
	$(".mbb").on('click',function(){
		var mbbId=$(this).attr('id');
		window.location="/mbkhxt/editKhMb.action?id="+mbbId+"&type=old";
		
	});
	//顶部菜单栏的事件绑定
	$("li.maintain").hover(function(){
		$(this).find('a:first').addClass("hover");
		var current_li=$(this);
		NavWaitSlide=setTimeout(function(){
			if(!$(current_li).children('ul').is(':visible')){
				$(current_li).find('ul').slideDown(300);
			}
		},100);
	},function(){
		clearTimeout(NavWaitSlide);
		$(this).find('ul').slideUp(300);
		$(this).find('a:first').removeClass("hover");
	});
	$("#createKhDx").on('click',function(){
		$("#createDxModal").modal('show');
	});
	$(".form").on('click',function(){
			$("#khmb_del").val($(this).find("td input").val());
			$("#deleteModal").modal('show');
	});
	$("#khmb_del").on('click',function(){
		var formId=$(this).val();
		$.ajax({
			type:"post",
			data:{formId:formId},
			url:"deleteForm.action",
			success:function(data){
				var jsonObject=eval("("+data+")");
				if(jsonObject["success"]){
					toast.success("删除成功", "温馨提示");
					$("#deleteModal").modal('hide');
					$("#"+formId).remove();
					$("#formId"+formId).parent().parent().remove();
				}else{
					//toast.error("删除失败", "温馨提示");
				}
			},
			error:function(data){
				//toast.error("请求失败", "温馨提示");
			}
		});
	});
	$("#addMbForm").on('click',function(){
		$("#addMbModal").modal('show');
	});
	$("#createDx").submit(function(){
		alert("sdadasd");
		return false;
	});
	$(".dx").on('click',function(){
		var name=$(this).find("#dxName").val();
		var zpOaid=$(this).find("#zpOaid").val();
		var dfOaid=$(this).find("#dfOaid").val();
		var note=$(this).find("#note").val();
		var id=$(this).find("#dxId").val();
		var remoteId=$(this).find("#remoteId").val();
		var dlId=$(this).find("#dxDlId").val();
		$.ajax({
			type:"GET",
			/*crossDomain: true,  
			dataType: 'jsonp', */ 
			url:"/mbkhxt/webService/show/tchuman/getTchumanByunitid/"+remoteId,
			success:function(data){
				var jsonArray=eval(data);
				$("#modalZpSelect option").remove();
				$("#modalKhSelect option").remove();
				//alert(jsonObject.data.rows[0].humanName);
				for(var i=0;i<jsonArray.length;i++){
					if(zpOaid==jsonArray[i].humanId){
						$("#modalZpSelect").append("<option selected='selected' value='"+jsonArray[i].humanId+"'>"+jsonArray[i].humanName+"</option>");
					}else{
						$("#modalZpSelect").append("<option value='"+jsonArray[i].humanId+"'>"+jsonArray[i].humanName+"</option>");
					}
					if(dfOaid==jsonArray[i].humanId){
						$("#modalKhSelect").append("<option selected='selected' value='"+jsonArray[i].humanId+"'>"+jsonArray[i].humanName+"</option>");
					}else{
						$("#modalKhSelect").append("<option value='"+jsonArray[i].humanId+"'>"+jsonArray[i].humanName+"</option>");
					}
				}
			},
			error:function(data){
				console.info(data);
			}
		});
		$("#modalName").val(name);
		$("#modalNote").val(note);
		$("#modalZpOaid").val(zpOaid);
		$("#modalDfOaid").val(dfOaid);
		$("#modalDxId").val(id);
		$("#modalDl").val(dlId);
		$("#modalRemoteId").val(remoteId);
		$("#dxModal").modal('show');
	});
	$(".zb").on('click', function() {
		var name=$(this).find("td:first").next().text();
		var order=$(this).find("td:first").text().trim();
		var score=$(this).find("td:last").text();
		var deptId=$(this).attr('id');
		$("#zbName").val(name);
		$("#zbScore").val(score);
		$("#zbOrder").val(parseInt(order));
		$("#saveZbBtn").css('visibility','visible');
		$("#deleteZbBtn").css('visibility','visible');
		$("#addZbBtn").css('visibility','hidden');
		$("#deleteZbBtn").val($(this).find("input").val());
		$("#saveZbBtn").val($(this).find("input").val());
		$("#zbDx").val(deptId);
		$("#addZbModal").modal('show', 'center');
	});
	$(".editXm").on('click', function() {
		var type=parseInt($(this).next().val());
		var name = $(this).parent().next().text();
		var score = $(this).parent().next().next().text();
		var khDx = $(this).parent().next().next().next().text();
		var order=$(this).parent().next().next().next().next().text();
		$("#saveXmBtn").val($(this).val());
		$("#deleteXmBtn").val($(this).val());
		showEditXm(name, score, khDx,type,order);
	});
	$("td").hover(function() {
		$(this).find(".rsp").stop().fadeTo(500, 0.5);
		$(this).find("#insert").stop().animate({
			left : '0'
		}, {
			duration : 500
		});

	}, function() {
		$(this).find(".rsp").stop().fadeTo(500, 0);
		$(this).find("#insert").stop().animate({
			left : '1000'
		}, {
			duration : "fast"
		});
	});
	// 控制右下返回顶部的按钮显示
	$(window).scroll(function() {
		var top = $(document).scrollTop();
		if (top > 300) {
			$("#goTopBtn").css('display', 'block');
		} else {
			$("#goTopBtn").css('display', 'none');
		}
	});
	$(".addZb").on('click', function() {
		$("#addZbModal").modal('show', 'center');
		$("#saveZbBtn").css('visibility','hidden');
		$("#deleteZbBtn").css('visibility','hidden');
		$("#addZbBtn").css('visibility','visible');
		$("#zbDx").val(0);
		$("#addZbBtn").attr('name', $(this).attr('name'));
		clearInput("#addZbModal input");
	});
	$("#deleteZbBtn").on('click',function(){
		var zbId=$(this).val();
		$.ajax({
			type:"post",
			data:{zbId:zbId},
			url:"deleteKhZb.action",
			success:function(data){
				var jsonObject=eval("("+data+")");
				if(jsonObject["success"]){
					location.reload(true);
				}else{
					toast.error("删除请求失败", "温馨提示");
				}
			}
		});
	});
	$("#saveZbBtn").on('click',function(){
		var name = $("#zbName").val().trim();
		var score = $("#zbScore").val();
		var deptId = $("#zbDx").val();
		var note = $("#zbNote").val();
		var zbId=$(this).val();
		var zbOrder=$("#zbOrder").val();
		if(deptId==0||name==""){
			toast.error("请填写完整信息", "温馨提示");
		}else{
			$.ajax({
				type : "post",
				data : {
					name : name,
					score : score,
					note : note,
					deptId : deptId,
					zbId:zbId,
					zbOrder:zbOrder
				},
				url : "updataKhZb.action",
				success : function(data) {
					var jsonObject = eval("(" + data + ")");
					if (jsonObject["success"]) {
						toast.success("创建成功", "温馨提示");
						location.reload(true);
					}
				},
				error : function(data) {
					toast.error("更新失败", "温馨提示");
				}
			});
		}
	});
	
	$("#addZbBtn").on('click', function() {
		var name = $("#zbName").val().trim();
		var score = $("#zbScore").val();
		var deptId = $("#zbDx").val();
		var note = $("#zbNote").val();
		var xmId = $(this).attr('name');
		var order=$("#zbOrder").val();
		if(deptId==0){
			toast.error("请填写完整信息", "温馨提示");
		}else{
			$.ajax({
				type : "post",
				data : {
					name : name,
					score : score,
					note : note,
					deptId : deptId,
					xmId : xmId,
					zbOrder:order
				},
				url : "createKhZb.action",
				success : function(data) {
					var jsonObject = eval("(" + data + ")");
					if (jsonObject["success"]) {
						toast.success("创建成功", "温馨提示");
						addKhZb(jsonObject["khZb"]);
						$("#addZbModal").modal('hide');
					}
				},
				error : function(data) {

				}
			});
		}
	});
	$("#addXm").on('click', function() {
		$("#addXmBtn").css('visibility', 'visible');
		$("#saveXmBtn").css('visibility', 'hidden');
		$("#deleteXmBtn").css('visibility', 'hidden');
		$("#addXmModal").modal('show', 'center');
		clearInput("#addXmModal input");
	});

	$("#addXmBtn").on('click', function() {
		var xmName = $("#xmName").val();
		var xmScore = $("#xmScore").val();
		var xmNote = $("#xmNote").val();
		var xmKhDx = $("#xmKhDx").val();
		var xmType=parseInt($("#xmType").val());
		var xmOrder=$("#xmOrder").val();
		is_commons = xmKhDx;
		var formId = $(this).val();
		if(isNaN(xmScore)||xmName==""){
			toast.error("分值栏，请填写正确的数字,并填写必填信息", "温馨提示");
		}else{
			$.ajax({
				type : "post",
				data : {
					formId : formId,
					name : xmName,
					note : xmNote,
					is_common : xmKhDx,
					score : xmScore,
					xmType:xmType,
					xmOrder:xmOrder
				},
				url : "createKhXm.action",
				success : function(data) {
					var jsonObject = eval("(" + data + ")");
					if (jsonObject["success"]) {
						//toast.success("创建成功！", "温馨提示");
						setTimeout(function(){
							window.location="/mbkhxt/editFormAction.action?formId="+formId;
						},1500);
						toast.success("创建成功",
								"温馨提示");
						addKhXm(jsonObject);
						clearInput("#addXmModal input");
						$("#addXmModal").modal('hide');
					} else {
						toast.error("创建失败", "温馨提示");
					}
				},
				error : function(data) {
					toast.error("请求失败", "温馨提示");
				}
			});
		}
	});
	$("#saveXmBtn").on('click', function() {
		var xmName = $("#xmName").val();
		var xmScore=parseFloat($("#xmScore").val().trim());
		if(isNaN(xmScore)||xmName==""){
			toast.error("分值栏，请填写正确的数字,并填写必填信息", "温馨提示");
		}else{
			var xmNote = $("#xmNote").val();
			var xmKhDx = $("#xmKhDx").val();
			var xmId = $(this).val();
			var xmType=parseInt($("#xmType").val());
			var xmOrder=$("#xmOrder").val();
			is_commons = xmKhDx;
			var formId = $(this).val();
			$.ajax({
				type : "post",
				data : {
					formId : formId,
					name : xmName,
					note : xmNote,
					is_common : xmKhDx,
					score : xmScore,
					xmId : xmId,
					xmType:xmType,
					xmOrder:xmOrder
				},
				url : "updataKhXm.action",
				success : function(data) {

					location.reload(true);

				},
				error : function(data) {
					toast.error("请求失败", "温馨提示");
				}
			});
			clearInput("#addXmModal input");
		}
	});
	$("#deleteXmBtn").on('click', function() {
		var xmId = $(this).val();
		$.ajax({
			type : "post",
			data : {
				xmId : xmId
			},
			url : "deleteKhXm.action",
			success : function(data) {
				toast.success("删除成功", "温馨提示");
				location.reload(true);
			},
			error : function() {
				toast.error("删除失败", "温馨提示");
			}
		});
	});
	$("#goTopBtn").click(function() {
		var sc = $(window).scrollTop();
		$('body,html').animate({
			scrollTop : 0
		}, 500);
	});
	$('#createKhDl').on('click', function() {
		var dlName = $('#dlName').val();
		var note = $('#note').val();
		if (dlName != null && dlName != "") {
			var params = $("input").serialize();
			$.ajax({
				type : "post",
				data : params,
				url : "creatKhDl.action",
				success : function(data) {
					var jsonObject = eval("(" + data + ")");
					if (jsonObject["success"]) {
						toast.success("创建大类成功", "温馨提示");
						$("#createDlModal").modal('hide');
						addKhDL(jsonObject["khdl"]);
						clearInput();
					} else {

					}
				},
				error : function(data) {

					toast.error("创建失败", "温馨提示");
				}

			});
		} else {
			toast.error("请填写完整的内容", "温馨提示");
		}
	});
	$("#btn_delete").on('click', function() {
		$("#myModal").modal('hide');
		var id = $(this).val();
		$.ajax({
			type : "post",
			data : {
				id : id
			},
			url : "deleteKhDl",
			success : function(data) {
				var jsonObject = eval("(" + data + ")");
				if (jsonObject["success"]) {
					toast.success("成功删除分组!", "温馨提示");
					var idStr = "#dl" + id;
					$(idStr).remove();
				} else {
					toast.error("删除失败", "温馨提示");
				}
			},
			error : function(data) {
				toast.error("请求失败", "温馨提示");
			}
		});
	});
	$("#createKhForm").on('click', function() {
		var name = $("#name").val();
		var note = $("#note").val();
		var year = $("#year").val();
		var dlId = $("#dl").val();

		$.ajax({
			type : "post",
			data : {
				year : year,
				name : name,
				note : note,
				dlId : dlId
			},
			url : "createKhForm.action",
			success : function(data) {
				var jsonObject = eval("(" + data + ")");
				if (jsonObject["success"]) {
					toast.success("创建考核表成功，请为其分配项目后生成真正的考核表", "温馨提示");
					addKhForm(jsonObject["khForm"]);
					$("#addXmModal").modal('hide');
				} else {
					toast.error(jsonObject["message"], "温馨提示");
				}
				clearInput();
			},
			error : function(data) {
				toast.error("请求失败", "温馨提示");
				clearInput();
			}
		});
	});
	$("#saveKhForm").on('click', function() {
		var formId = $(this).val();
		var name = $("#name").val();
		var note = $("#note").val();
		var year = $("#year").val();
		var dlId = $("#dl").val();
		var scoreCountType=$("#scoreCountType").val();
		$.ajax({
			type : "post",
			data : {
				formId : formId,
				name : name,
				note : note,
				year : year,
				dlId : dlId,
				scoreCountType:scoreCountType
			},
			url : "updateKhForm.action",
			success : function(data) {
				var jsonObject = eval("(" + data + ")");
				if (jsonObject["success"]) {
					toast.success("保存修改成功", "温馨提示");
					$("#year").val(jsonObject["khForm"].year);
					// $("#dl").val(jsonObject["khForm"]["khDl"].khDlId);
					$("#name").val(jsonObject["khForm"].name);
					$("#note").val(jsonObject["khForm"].note);

				} else {
					toast.error("请填写完整内容", "温馨提示");
				}
			},
			error : function(data) {
				toast.error("请求失败,请稍候再试", "温馨提示");
			}
		});
	});
	
	$(".khFormType").on('click',function(){
		var typeId=$(this).attr('id');
		var typeName=$(this).find("td:last").text().trim();
		var $typeModal=$("#formTypeModal");
		$typeModal.find("#typeName").val(typeName);
		$typeModal.find("#formTypeId").val(typeId);
		$("#formTypeModal").modal('show');
	});
	$("#copyKhmb").on('click',function(){
		var dlId=$("tr.dl.selected").attr('id');
		$.ajax({
			type:"get",
			url:"webService/show/khDlService/getKhDls",
			success:function(data){
				/*var jsonObject=eval("("+data+")");*/
				var jsonArray=data["khDl"];
				$("#copykhDlid option").remove();
				$("#copykhDlid").prepend("<option value="+0+">请选择</option>");
				$("#khDlId option").remove();
				$("#khDlId").prepend("<option value="+0+">请选择</option>");
				$(jsonArray).each(function(index,ele){
					var dlId=ele["khDlId"];
					var name=ele["khDlName"];
					$("#copykhDlid").prepend("<option value="+dlId+">"+name+"</option>");
					$("#khDlId").prepend("<option value="+dlId+">"+name+"</option>");
				});
			}
		});
		$("#copyFlmb").modal('show');
	});
	$("#copykhDlid").change(function(){
		var dlId=$(this).val();
		$.ajax({
			type:"get",
			url:"webService/show/khmbfl/getKhMbs/"+dlId,
			success:function(data){
				$("#mbbb option").remove();
				$("#mbbb").prepend("<option value="+0+">请选择</option>");
				$(data).each(function(index,ele){
					$("#mbbb").prepend("<option value="+ele["khFlmbId"]+">"+ele["year"]+ele["name"]+"</option>");
				});
			}
		});
	});
	
});
function back(){
	window.history.go(-1);
}
function showEditXm(name, score, khDx,type,order) {
	$("#xmName").val(name);
	$("#xmScore").val(score);
	$("#xmType").val(type);
	$("#xmOrder").val(order);
	if (khDx == "是") {
		$("#xmKhDx option:frist").attr('selected', 'selected');
	} else {
		$("#xmKhDx option").each(function() {
			var text = $(this).text();
			if ($(this).text() == khDx) {
				$(this).attr('selected', 'selected');
			}
		});
	}
	$("#addXmBtn").css('visibility', 'hidden');
	$("#saveXmBtn").css('visibility', 'visible');
	$("#deleteXmBtn").css('visibility', 'visible');
	$("#addXmModal").modal('show', 'center');
}
function deleteDl(id) {
	
	$("#btn_delete").val(id);
	$("#myModal").modal('show', 'center');
	$("a").onclick(function(event){
		return false;
	});
}

function clearInput(id) {
	if (id == 0) {
		$(":input").each(function() {
			$(this).val("");
		});
	} else {
		$(id).each(function() {
			$(this).val("");
		});
	}
	$("#addXmModal select").each(function(){
		$(this).val(0);
	});

}

function addKhZb(khZb) {
	var trName = "." + khZb.khXmId;
	var zbStr = "<tr class=\"zb\" id=\""+khZb.deptId.khDxId+"\">" + "<td >" + khZb.order + "</td>"+
	"<td style=\"width: 400px;\">" + khZb.name+
	"<input type=\"hidden\" value=\""+khZb.khZbId+"\" /> </td>"
			+ "<td >" + khZb.deptId.khDxName + "</td>"
			+ "<td class=\" min-4\">" + khZb.score + "</td>" + "</tr>";
	$(trName + " td").each(function() {
		var num = parseInt($(this).attr('rowspan')) + 1;
		$(this).attr('rowspan', num);
	});
	$(trName).after(zbStr);
}

function addKhXm(jsonObject) {
	var khXm = jsonObject["khXm"];
	var count = jsonObject["xmCount"];
	var conStr = "是";
	if (is_commons != 0) {
		conStr = khXm.khDx.khDxName;
	}
	var xmStr = "<tr>" + "<td rowspan=\"2\">" + count + "</td>"
			+ "<td rowspan=\"2\">" + khXm.name + "</td>" + "<td rowspan=\"2\">"
			+ khXm.score + "</td>" + "<td rowspan=\"2\">" + conStr + "</td>"
			+ "</tr><tr>" + "<td colspan=\"1\">"
			+ "<button class=\"btn btn-default addZb\" name="
			+ khXm.khXmId + "  type=\"button\">添加指标</button>" + "</td>"
			+ "<td colspan=\"1\">" + "无" + "</td>"+"<td colspan=\"1\">" + "无" + "</td>" + "</tr>";
	$(xmStr).appendTo("#xmtbody");

}
function addKhForm(khForm) {
	var dxList = khForm.khDl.khDxs;
	var dxsStr = "";
	for ( var i = 0; i < dxList.length; i++) {
		dxsStr = dxsStr + "<li >" + dxList[i].khDxName + "</li>";
	}
	var formStr = "<s:a action=\"editFormAction\">"
			+ "<div class=\"col-md-3 kh_form\">" + "<p class=\"\">" + "标题:"
			+ khForm.name + "</p>" + "<div class=\"row  pl_0\">"
			+ "<p class=\"col-md-6\">" + "年度:" + khForm.year + "</p>"
			+ "<p class=\"col-md-6\">考核对象</p>" + "</div>"
			+ "<div class=\"div_line\"></div>" +

			"<ul class=\"ul_left\">" + dxsStr + "</ul>" + "</div>" + "</div>"
			+ "</s:a>";
	$(formStr).prependTo("#formList");
}

function addKhDL(khDl) {

	var dlStr = "<div class=\"col-md-3 kh_form \" id=dl" + khDl.khDlId + ">"
			+ "<div class=\"row\">" + "<p class=\"col-md-10\">" + khDl.khDlName
			+ "</p>" + "<ul class=\"mr_10 col-md-1 ul_left_icon\">"
			+ "<li onclick=\"deleteDl(" + khDl.khDlId
			+ ")\" class=\"glyphicon glyphicon-remove\"></li>" + "</ul>"
			+ "</div>" +

			"<div class=\"div_line\"></div>" + "<ul class=\"ul_left\">" +

			"<li class=\"\"></li>" +

			"</ul>" + "</div>";
	$(dlStr).prependTo("#dlList");
};

function dxEdit(type){
	if(type==1){
		$("#dxEditForm").attr("action","updateDxAction.action").submit();
	}
	if(type==2){
		$("#dxEditForm").attr("action","deleteKhDxAction.action").submit();
	}
}


function zbAction(url){
	alert(url);
}
function mySubmit(flag){
	return flag;
};